package com.sskj.gocoin.mine;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Button;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.sskj.gocoin.R;
import com.sskj.gocoin.R2;
import com.sskj.gocoin.adapter.HbAdapter;
import com.sskj.gocoin.common.widget.ToolBarLayout;
import com.sskj.gocoin.mine.data.BenefitBean;
import com.sskj.gocoin.mine.data.TuiguangBean;
import com.sskj.gocoin.utils.ClickUtil;
import com.sskj.gocoin.v.base.BaseActivity;
import com.sskj.lib.RConfig;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class HBActivity extends BaseActivity<HBPresenter> {

    @BindView(R2.id.toolbar)
    ToolBarLayout toolbar;
    @BindView(R2.id.rv_hb)
    RecyclerView hbRv;
    @BindView(R2.id.tvCancel)
    TextView tvCancel;

    private List<String> data = new ArrayList<>();

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_hb;
    }

    @Override
    public HBPresenter getPresenter() {
        return new HBPresenter();
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initView() {
        toolbar.setLeftButtonOnClickLinster(v -> finish());
        ClickUtil.click(tvCancel, new ClickUtil.Click() {
            @Override
            public void click() {
                finish();
            }
        });

        hbRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
        hbRv.setAdapter(new HbAdapter(this, data));
    }

    @Override
    protected void initData() {
        mPresenter.getTuiGuang();
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, HBActivity.class);
        context.startActivity(intent);
    }

    public void onGetTuiguang(TuiguangBean tuiguangBean) {
        data.clear();
        data.addAll(tuiguangBean.getQrc());
        hbRv.getAdapter().notifyDataSetChanged();
    }
}
